<template>
  <div>
    <div class="boxx">
      <div class="box-con">
        <div class="box-leftt">
          <div class="fenleikk">
            <div v-for="group in table" :key="group.id" class="erwushi">
              <h3>{{ group.month }}</h3>
              <div
                class="duibul"
                @click="funxiang(item.id)"
                v-for="(item, index) in group.articles"
                :key="index"
              >
                <img :src="item.titleImage" alt="" />
                <div class="geiwo">
                  <p>{{ item.title }}</p>
                  <span><i class="el-icon-date"></i>{{ item.createTime }}</span>
                </div>
              </div>
            </div>
          </div>
          <div class="block">
            <span class="demonstration"></span>
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="ruleFrom.current"
              :page-sizes="[10, 20, 30, 40]"
              :page-size="ruleFrom.size"
              layout="total, sizes, prev, pager, next, jumper"
              :total="ruleFrom.total"
            >
            </el-pagination>
          </div>
        </div>
        <div class="right">
          <div class="right-tou">
            <img :src="cxk.avatar" alt="" />
            <h3>{{ cxk.author }}</h3>
            <p>{{ cxk.introduction }}</p>
          </div>
        </div>
      </div>
    </div>
    <div class="box-xiaa">
      <div class="box-xia-comm">
        <div>
          © 2023
          <span>Weblog™.</span>
          All Rights Reserved.
        </div>
        <div>Provided by <span>犬小哈</span></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      cxk: {},
      table: [],
      ruleFrom: {
        current: 1,
        size: 10,
        total: 0,
      },
    };
  },
  created() {
    this.getAdd();
    this.getList();
  },
  methods: {
    funxiang(articleId) {
      this.$router.push({
        path: "/home/shouxiang",
        query: { articleId: articleId },
      });
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.ruleFrom.size = val;
      this.getList();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.ruleFrom.current = val;
      this.getList();
    },
    async getList() {
      let res = await this.$axios.post(
        "http://47.104.167.34:9110/api/archive/list",
        {
          current: this.ruleFrom.current,
          size: this.ruleFrom.size,
        }
      );
      console.log(res);
      this.table = res.data.data;
      this.ruleFrom.total = res.data.total;
      // console.log(this.table);
    },
    async getAdd() {
      let res = await this.$axios.post(
        "http://47.104.167.34:9110/api/blog/setting/detail"
      );
      // console.log(res);
      this.cxk = res.data.data;
    },
  },
};
</script>

<style>
@import "./guidang.css";
</style>